#ifndef _Emulator_H_
#define _Emulator_H_

#include <vector>
#include <list>
#include <deque>
#include <memory>
#include "Program.h"
#include "InfoAnalizer.h"

class Emulator {
private:
  //program index, which created lock
  //0, if there is no lock
  int lockId;
  std::deque<int> blockProgramsIds;  
  
  std::vector<Program> programs;
  
  std::auto_ptr<IVariableDict> variables;  

  std::ostream &outStream;

  void executeBlockCandidate();
  
  void executeProgramVector();
  
  void deleteFinishedPrograms();

  void resetProgramsState();
  InfoAnalizer infoAnalizer;
public:
  
  Emulator(const std::list<std::string> &lines, std::ostream &outStream_);

  void execute();

  ~Emulator();
};


#endif